<template>
  <div class="form_box">
    <avue-form :option="option" v-model="crudData.form" @submit="handleSubmit">
    </avue-form>
  </div>
</template>
<script setup>
import Editor from '@/components/Editor/index.vue';
import {configList, configPut} from "@/api/user/index.js";
import {ElMessage} from "element-plus";
import {onMounted} from "vue";

let props = defineProps({
  content: {
    type: Object,
    default: () => [],
    required: true
  }
})
// const emit = defineEmits(['changeTab'])
const crudData = reactive({
  form: {},
  nowData: {},
})
const option = reactive({
  labelWidth: 150,
  size: 'medium',
  column: [
    {
      label: '平台APP下载',
      prop: 'platform_app_download',
      span: 24,
      component: Editor,
    },
    {
      label: 'VIP等级权益说明',
      prop: 'vip_level_benefits_description',
      span: 24,
      component: Editor,
    },
    {
      label: '公司简介',
      prop: 'company_profile',
      span: 24,
      component: Editor,
    },
  ]
})
const handleSubmit = (form, done) => {
  let params = {}
  params.project = form
  console.log('form', params)
  configPut(params).then(res => {
    ElMessage.success('操作成功')
    initData()
    // emit('changeTab')
  }).catch(err => {
  })
  done()
}
const initData = async () => {
  await configList().then(res => {
    crudData.form = res.data.project
  })
}
onMounted(() => {
  initData()
})
</script>
<style scoped lang="scss">
.form_box {
  width: 100%;
  padding: 0 20px 20px 20px;
  height: calc(100vh - 120px);
  overflow-y: auto;

  ::v-deep .avue-form {
    .el-collapse-item__wrap {
      padding: 20px;
    }
  }
}
</style>
